package top.malaoshi.ctrl;



import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import top.malaoshi.model.Result;
import top.malaoshi.service.RegSrvImpl;

import javax.annotation.Resource;

@RestController
public class RegCtrl {
    @Resource
    private RegSrvImpl srv;
    @RequestMapping("/reg")
    public Result reg(String password, String phone) {
        Result mv=new Result();
        if(phone==null||"".equals(phone)){
            mv.setCode(1101);
            mv.setMsg("你们难道没有手机吗？");
            return mv;
        }
        if(password==null||"".equals(password)){
            mv.setCode(1102);
            mv.setMsg("你家大密密呢？");
            return mv;
        }
        Result res=srv.reg(password,phone);
        if(res.getCode()==0){
            mv.setCode(1100);
            mv.setMsg("注册成功？");
            return mv;
        }else{
            mv.setCode(1104);
            mv.setMsg("该用户已经存在？");
            return mv;
        }
    }
}